<?php

namespace Modules\Admin\Tests\Unit;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Passport\ClientRepository;
use Modules\Admin\Entities\Admin;
use Modules\Admin\Services\AdminService;
use Spatie\Activitylog\Models\Activity;
use Tests\AdminTestCase;

class AdminServiceTest extends AdminTestCase {
    use RefreshDatabase;

    public function testAa(){
        $modelName = "Modules\Admin";
        $name = class_basename($modelName) . 'Policy';
        $arr = explode('\\', $modelName);
        if (count($arr)==2){
          $str =  "$arr[0]\\Policies\\$name";
        }else{
           $str= "$arr[0]\\$arr[1]\\Policies\\$name";
        }
        dd($str);
        $modelName = Admin::factory()->create();

        $name = class_basename($modelName) . 'Policy';
        $arr = explode('\\', $modelName);

        dd($name,$arr);
        //             dd("$arr[0]\\$arr[1]\\Policies\\$name");
        return "$arr[0]\\$arr[1]\\Policies\\$name";
    }
    public function testUpdate() {
        $this->admin->update(['password' => 1, 'username' => 'aaa']);
        activity()
            ->performedOn($this->admin)
            ->causedBy($this->admin)
            ->withProperties(['laravel' => 'awesome'])
            ->log('The subject name is :subject.name, the causer name is :causer.name and Laravel is :properties.laravel');

        dd(Activity::query()->get()->toArray());
    }
}
